<?php
$pagename= "Data Entry- Books";
require_once "auth.php";
include "connect.php";
include "header.php";

if (isset($_GET["code"])) {
$barcode= $_GET["code"];
//this clears all veribles to prevent errors later
$sql_select = "SELECT * FROM books WHERE barcode = '$barcode'";
$fetch = mysql_query($sql_select);
$book_fetch = mysql_fetch_array($fetch);
$name = $book_fetch['name'];
$barcode = $book_fetch['barcode'];
$author_first = $book_fetch['author'];
$author_last = $book_fetch['author_last'];
$call = $book_fetch['callnum'];
$publisher = $book_fetch['publisher'];
$yearpub = $book_fetch['year_pub'];
$edition = $book_fetch['edition'];
$fiction = $book_fetch['fiction'];
$inhouse = $book_fetch['in_house'];


if (isset($_GET['status'])) {
echo "Form Processing...<br>Done!";
if ($_GET['status'] == "added") {
echo "<h3><font color='green'>SUCCESS! Book Edited</font>";
}

}
	
		?>
		
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>


</head>
<body>
<form method="get" action="editbook_go.php" >

Book Name <input type="text" value="<?echo $name;?>" id="name"size="80" name="bookname"/><br>

Author Last Name <input type="text" value="<?echo $author_last;?>" id="auth1" size="80" name="authlast"/><br>

Author First Name <input type="text" value="<?echo $author_first;?>" id="auth2" size="80" name="authfirst"/><br>

Publisher <input type="text" value="<?echo $publisher;?>" id="pub"size="80" name="publisher"/><br>

Year of Publication (ex. 1990) <input type="text" value="<?echo $yearpub;?>" id="year" size="4" name="yearpub"/><br>


 

Edition ("1" if it can not be found):<input type="text" value="<?echo $edition;?>" id="year" size="4" name="edition"/><br>

Dewey Decimal / Call Number  <input type="text" value="<?echo $call;?>" id="gen" size="80" name="call"/><br>
 
Fiction or Non-Fiction?

<input type="radio" name="fiction" value="true" <? if ($fiction == "true") { echo "checked";}?>  /> Fiction<br />
<input type="radio" name="fiction" value="false" <? if ($fiction == "false") { echo "checked";}?>/> Non-Fiction <br>

In House Use Only: Yes <input type="radio" name="inhouse" value="true" <? if ($inhouse == "false") { echo "checked";}?>/> No <input type="radio" name="inhouse" value="false"  <? if ($inhouse == "false") { echo  "checked";}?>/>  <br>

<input type='text' value='<?php echo $barcode; ?>' name='code' hidden/>
<input type="submit" id="register" value="Register" />
</form>


</body>
</html>
<?}
?>